
package com.yungu.swift.system.marketing.dao;


import com.yungu.swift.base.mapper.IMapper;
import com.yungu.swift.system.marketing.model.dto.MarketingGiftCodeDto;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * MarketingCouponMapper数据库操作接口类
 **/

public interface MarketingGiftCodeMapper extends IMapper<MarketingGiftCodeDto> {
    /**
     * 批量插入
     *
     * @param list List
     * @return int
     */
    int addBatch(List list);

    /**
     *
     *
     * @param code String
     * @return MarketingGiftCodeDto
     */
    @Select("select * from t_marketing_gift_code where code = #{code} limit 1")
    MarketingGiftCodeDto findByCode(@Param("code") String code);

    /**
     * disableCode
     *
     * @param code String
     * @return int
     */
    @Update("update t_marketing_gift_code set used = 1 where code=#{code}")
    int disableCode(@Param("code") String code);

    /**
     * 查找重复的兑换码
     *
     * @param redeemCodeList List
     * @return List<String>
     */
    List<String> findRepeatRedeemCodes(List<String> redeemCodeList);

    /**
     * findCDKeyByGiftUuid
     *
     * @param giftUuid String
     * @return List<String>
     */
    @Select("select code from t_marketing_gift_code where gift_uuid= #{giftUuid}")
    List<String> listCDKeyByGiftUuid(@Param("giftUuid") String giftUuid);
}